package com.wac.data.utils;

import com.wac.data.entity.User;
import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

public class CreateToken {

	public String getoken(User user) {
		Jwts.builder();//生成
		Jwts.parser();//解密

		JwtBuilder jwtBuilder = Jwts.builder()
				.setId(user.getId())//设置需要加密的内容
				.setSubject(user.getEmail())
				.setIssuedAt(new Date())//token保留时间
				.signWith(SignatureAlgorithm.HS256, "my-123")
				.setExpiration(
						new Date(new Date().getTime() + 86400000)
				);
		return jwtBuilder.compact();
	}

}
